﻿

document.oncontextmenu = function() {return false;}
  
function openWindow(id) {  
 
 count = document.getElementById("count").value;
 count = parseInt(count) + parseInt(id);
 
 dragObjCloneArray[id].style.display='block';
 dragObjCloneArray[id].style.visibility='visible';
 
 document.getElementById('window('+id+')').style.display='block';
 document.getElementById('window('+id+')').style.visibility='visible';
 
 document.getElementById('task('+id+')').style.display='block';
 document.getElementById('dragable('+count+')').style.zIndex='1000';

 document.getElementById('frame('+id+')').style.display='block';

 hideObject('startmenu');
      
  }
  
function obturate(id) {

 document.getElementById('frame('+id+')').src = document.getElementById('frame('+id+')').src


  document.getElementById('window('+id+')').style.display='none';
  document.getElementById('window('+id+')').style.visibility='hidden';
    document.getElementById('task('+id+')').style.display='none';
     dragObjCloneArray[id].style.zIndex = '0';  }
          
function minimize(id) {document.getElementById('window('+id+')').style.display='none';}
function restore(id) {document.getElementById('window('+id+')').style.display='block';}

function maximize(id) {document.getElementById('window('+id+')').style.width='100%';}
                    
 function raditGaldu() {
 
 //for(i=0;i<3;i++) {document.getElementById(menus[i]).style.visibility='hidden'}; 
 //for(i=0;i<1;i++) {document.getElementById(logi[i]).style.display='none'}
 
 }
 
 function show_tapetes() {document.getElementById('tapetes_drop').style.visibility='visible';}
 function hide_tapetes() {document.getElementById('tapetes_drop').style.visibility='hidden';}
  
  
  
function styles() { }     
   
function doresize(id) {

document.getElementById('t'+id).width="800px;"; id = id + 1;
document.getElementById('t'+id).width="800px;"; id = id + 1;
document.getElementById('t'+id).width="800px;"; 

}   

function showBody() {document.body.style.display = 'block'}

function initialize(access) {


//ajaxRequest("content","content.aspx","true");
//loadSettings();

    initdragableElements(); 
    
    showTime();
    showBody(); 

if(access!="admin") {

    $('#iconMenu').disableContextMenuItems('#changeicon,#changename,#changeaccess,#delete,#copy,#asign');
    $('#defaultMenu').disableContextMenuItems('#file,#icon,#user,#refresh,#reloads');

}

}



function setWallpaper(wallpaper) { 

 if (document.images)
    {
      preload_image = new Image(25,25); 
      preload_image.src = wallpaper
    }

 var wallpaper = document.getElementById("wallpaper").src = wallpaper; 
  
    }
  
function startmenu() { 

  if(testObject('startmenu'))
     {hideObject('startmenu')}
      else{showObject('startmenu');}
  
   }

function testObject(id) { 

  test = document.getElementById(id).style.visibility;
   if(test == 'visible') {return true;} 
    else{return false;}
    
   }


function delayclose() { timer = setTimeout("hideObject('startmenu')",2000);}
function canceldelay() { clearTimeout(timer); }

function showObject(id) {document.getElementById(id).style.visibility='visible';}
function hideObject(id) {document.getElementById(id).style.visibility='hidden';}



function loginUser() 

{  document.getElementById('startmenu').style.visibility='hidden';

    var login  = Prompt.show('Ievadiet loginu')
      if(login) { 
      
        var password  = Prompt.show('Ievadiet paroli');        
          if(password) {
          
            document.getElementById('systray').src = 'login.aspx?login=' + login + '&password=' + password
   
           }
            
         }
       
      }
      
 function shutDown()  {window.open('close.html','_self');}
 
 function deleteIcon(id)  {
 
    var c = confirm("Vai Tu esi parliecinats?");
     if(c) {document.getElementById('icon('+id+')').style.display = "none"}
          
       document.getElementById('systray').src = "icon.aspx?action=delete&order=" + id;
 	   document.getElementById('systray').src = ""
     		    
			    }
 
 
 function showTime(){
 if (!document.layers&&!document.getElementById&&!document.getElementById) {return;}
 
 var Digital = new Date();
 var hours = Digital.getHours();
 var minutes = Digital.getMinutes();
 var seconds = Digital.getSeconds();
 var dn = "AM"; 
 
 if (hours>12){ dn="PM";  hours=hours-12;}
 if (hours==0) {hours = 12;}
 if (minutes<=9) {minutes = "0"+minutes}
 if (seconds<=9) {seconds = "0"+seconds}

 myclock = hours + ":" + minutes + ":" + seconds + "&nbsp;" + dn;
 document.getElementById('time').innerHTML=myclock;
 setTimeout("showTime()",1000);}
 
 function openUploadFileDialogue(){
	var frm = document.form1.upload;
	if(document.all && document.getElementById){
		document.form1.upload.click();
	}
}

function setIconName(id,name) {
		             
  document.getElementById('task('+id+')').innerHTML = name;
  document.getElementById('iconTitle('+id+')').innerHTML = name;
  document.getElementById('windowName('+id+')').innerHTML = name;
		             
		             }    

function createUser() {

  var login  = Prompt.show('Ievadiet Jauna lietotāja loginu')
      if(login) { 
      
        var password  = Prompt.show('Ievadiet Jauna lietotāja paroli');    
         var email  = Prompt.show('Ievadiet Jauna lietotāja E-pastu');        
          if(password) { document.getElementById('systray').src = "user.aspx?action=add&login="+ login +"&password=" + password+"&email=" + email;  }
           
          
         } 
          

}

function giveAccess(level) {
  
  if(level == "admin") {
  
    c = confirm("Veiksmigi ieguti administratora tiesibas - pienemt??")
     if(c) { 
         $('#defaultMenu').enableContextMenuItems('#file,#icon,#user,#refresh,#reloads'); 
         $('#defaultMenu').disableContextMenuItems('#login'); 
          $('#iconMenu').enableContextMenuItems('#changeicon,#changename,#changeaccess,#delete,#copy,#asign');
         }
      }
      
       
  if(level == "user") {
    c = confirm("Veiksmīgi ieguti lietotāja tiesibas - pieņemt??")
     if(c) {}
     
      }
      
     if(level!="user" && level!="admin") {
     
     c = confirm("Nepareizi ielogošanas dati - atkartot??")
      if(c) {loginUser();}
     } 
    
  
}

function setWall(id) {

 if (document.images)
    {
      preload_image = new Image(25,25); 
      preload_image.src = wallpaper
    }

 var wallpaper = document.getElementById("wallpaper").src = "images/wallpapers/"+id+".jpg"; 


}